package com.zyuan.lawyerport.presenter.splash;

import android.app.Activity;
import android.content.Intent;
import android.os.Handler;

import com.zyuan.lawyerport.GuildActivity;
import com.zyuan.lawyerport.MainActivity;
import com.zyuan.lawyerport.R;
import com.orhanobut.logger.Logger;

import common.tool.PUB;

/**
 * description 程序装载类
 * Created by JustTong on 2018/11/28.
 */
public class SplashPresenterImpl implements SplashPresenter {
    private String getVersionCode;

    @Override
    public void startMainActivity(final Activity mActivity) {
        new Handler().postDelayed(new Runnable() {
            public void run() {
                mActivity.overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
                try {
                    getVersionCode = PUB.getVersionCode(mActivity);
                } catch (Exception ex) {
                    Logger.e(ex.toString());
                }
                String firstInIdentifying = PUB.SharedPreferences(mActivity, "firstInIdentifying", "#read");
                if (getVersionCode.equals(firstInIdentifying)) {
                    mActivity.startActivity(new Intent(mActivity, MainActivity.class));
//                    mActivity.startActivity(new Intent(mActivity, Main2Activity.class));
                } else {
                    mActivity.startActivity(new Intent(mActivity, GuildActivity.class));
                }
                mActivity.finish();
            }
        }, 10);

        //测试 AgentWeb
//        Intent mIntent = new Intent(mActivity,TestAgentWebActivity.class);
//        mActivity.startActivity(mIntent);

        //测试 自定义视频播放器
//        Intent mIntent = new Intent(this,CustomPlayerActivity.class);
//        startActivity(mIntent);

//        //测试 Retrofit2
//        NetworkCore.getInstances().test("name", "password").enqueue(new Callback<TestBean>() {
//            @Override
//            public void onResponse(Call<TestBean> call, Response<TestBean> response) {
//                String msg ="Response:Code=200 Msg=" + response.body().getMessage();
//                Logger.i(msg);
//                Toasty.info(mActivity, msg).show();
//            }
//
//            @Override
//            public void onFailure(Call<TestBean> call, Throwable t) {
//                String msg ="Error:" + "Code=1001 Msg="+t.getMessage();
//                Logger.e(msg);
//                Toasty.error(mActivity, msg).show();
//            }
//        });

    }

    @Override
    public void doActionData(Object mObject) {

    }


}
